#include "widget.h"
#include "ui_widget.h"
#include<QTimer>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lcdNumber->display("10");
    _time = new QTimer(this);
    connect(_time, &QTimer::timeout, this, &Widget::handle);
    //Qt休眠信号，单位ms（毫秒）
    _time->start(1000);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handle()
{
    int value = ui->lcdNumber->intValue();
    if(value <= 0)
    {
        _time->stop();
        return;
    }

    ui->lcdNumber->display(--value);

}

